<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            background-color: rgb(31, 32, 34);
        }

        .container {
            position: relative;
            /* perspective 3D 元素距视图的距离 */
            perspective: 2000px;
        }

        .imgBox {
            position: relative;
            width: 240px;
            height: 400px;
            transition: all 0.5s;
            /* 子元素3d位置 */
            transform-style: preserve-3d;
        }

        /* 鼠标移入 所有图片绕X轴旋转50度 */
        .imgBox:hover {
            cursor: pointer;
            transform: rotateX(50deg) rotateZ(-50deg);
        }

        /* 设置图片定位 让所有图片重叠在一起 */
        .imgBox img {
            position: absolute;
            width: 100%;
            height: 100%;
            box-shadow: 0 0 3px rgb(255, 255, 255);
            transition: all 1.5s;
            transform: translateZ(0px);
        }

        /* 给每一个图片设置xyz轴上的距离 这样就会实现分层效果 */

        .imgBox:hover img:nth-child(2) {
            transform: translateX(-10px) translateY(10px) translateZ(-10px);
            opacity: 0.8;
        }

        .imgBox:hover img:nth-child(3) {
            transform: translateX(-20px) translateY(20px) translateZ(-20px);
            opacity: 0.6;
        }

        .imgBox:hover img:nth-child(4) {
            transform: translateX(-30px) translateY(30px) translateZ(-30px);
            opacity: 0.4;
        }

        /* 最底层的蓝块 设置定位和过渡 */
        .imgBox span {
            position: absolute;
            width: 100%;
            height: 100%;
            opacity: 0.2;
            transition: all 0.5s;
        }

        .imgBox:hover span {
            transform: translateX(-40px) translateY(40px) translateZ(-40px);
            box-shadow: 0 0 40px rgb(42, 144, 245);
            background-color: rgb(15, 110, 206);
        }
    </style>
</head>

<body>
    <div class="container">
        <div class="imgBox">
            <img src="https://img0.baidu.com/it/u=2876201663,1031874670&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=1083"
                alt="">
            <img src="https://img0.baidu.com/it/u=2876201663,1031874670&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=1083"
                alt="">
            <img src="https://img0.baidu.com/it/u=2876201663,1031874670&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=1083"
                alt="">
            <img src="https://img0.baidu.com/it/u=2876201663,1031874670&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=1083"
                alt="">
            <span></span>
        </div>
    </div>
</body>

</html>